package com.quectel.sdk.quecentrance.entranceguard;

import com.quectel.sdk.quecentrance.QuecEntranceClientBuilder;
import com.quectel.sdk.quecentrance.entranceguard.model.QueryUserReq;
import com.quectel.sdk.quecentrance.entranceguard.model.QueryUserResp;
import com.quectel.util.common.JacksonUtils;
import com.quectel.util.http.HttpRestUtils;

import java.util.List;

/**
 * 在这里编写说明
 *
 * @author: ryan
 * @email: ryan.ran@quectel.com
 * @date: 2023-08-21 15:30:00
 */
public class EntranceGuardTest {

    private static final HttpRestUtils HTTP_REST_UTILS = HttpRestUtils.getDefaultInstance();

    private static final String KEY = "uy8t8a0zvvev3bql";
    private static final String SECRET = "q9s6t62gi60x7t7069g9ojx4unbe1lho";
    private static final String BASE_URL = "https://test-attendance.quectel.com/api/";

    public static void main(String[] args) {
//        long l = System.currentTimeMillis();
//        String sign = MD5.create().digestHex(l + "#" + SECRET);
//        Map<String, String > header = new HashMap<>();
//        header.put("appKey", KEY);
//        header.put("sign", sign);
//        header.put("timestamp", l + "");
//
//        String resp = HTTP_REST_UTILS.get(BASE_URL + "api/v1/subscribe/list", null, header, new TypeReference<String>() {
//        }).getRight();
//        System.out.println(resp);

        EntranceGuardClient build = QuecEntranceClientBuilder.builder()
                .appKey(KEY).appSecret(SECRET).baseUrl(BASE_URL)
                .build(EntranceGuardClient.class);

//        AddGroupReq addGroupReq = new AddGroupReq();
//        addGroupReq.setName("anson 访客测试组");
//        addGroupReq.setType("2");
//        addGroupReq.setModel("ATTENDANCE");
//        addGroupReq.setDeviceIds(new Long[]{4L});
//        Integer integer = build.addGroup(addGroupReq);
//        System.out.println(integer);

        QueryUserReq queryUserReq = new QueryUserReq();
        List<QueryUserResp> queryUserResps = build.queryUserList(queryUserReq);
        System.out.println(JacksonUtils.toJsonString(queryUserResps));
//
//        List<QueryGroupResp> queryGroupResps = build.queryGroupList(new QueryGroupReq());
//        System.out.println(JacksonUtils.toJsonString(queryGroupResps));

//        QueryDeviceReq queryDeviceReq = new QueryDeviceReq();
//        List<QueryDeviceResp> queryDeviceResps = build.queryDeviceList(queryDeviceReq);
//        System.out.println(JacksonUtils.toJsonString(queryDeviceResps));

//        boolean b = build.delGroup(2);
//        System.out.println(b);

//        AddPersonReq addPersonReq = new AddPersonReq();
//        addPersonReq.setName("于波波3");
//        addPersonReq.setMobile("18716457275");
//        Integer integer = build.addPerson(addPersonReq);
//        System.out.println(integer);
//
//        boolean b = build.delPerson(6808);
//        System.out.println(b);

//        AddVisitorReq addVisitorReq = new AddVisitorReq();
//        addVisitorReq.setName("anson");
//        addVisitorReq.setMobile("18716451234");
//        addVisitorReq.setDateTimeFrom(new Date());
//        addVisitorReq.setDateTimeTo(DateUtil.offsetDay(new Date(), 1));
//        Integer integer = build.addVisitor(addVisitorReq);
//        System.out.println(integer);

//        QueryUserReq queryUserReq = new QueryUserReq();
//        queryUserReq.setType(2 + "");
//        List<QueryUserResp> queryUserResps = build.queryUserList(queryUserReq);
//        System.out.println(JacksonUtils.toJsonString(queryUserResps));

//        File file =
//                FileUtil.file("/Users/ryan/Downloads/anson.jpeg");
//        String s = build.uploadAvatar(file);
//        if (StringUtils.isNotBlank(s)) {
//            System.out.println(s);
//            AddDeptPersonReq addPersonReq = new AddDeptPersonReq();
//            addPersonReq.setName("于波波3");
//            addPersonReq.setMobile("18716457272");
//            addPersonReq.setJobNumber("4533");
//            addPersonReq.setAvatar(s);
//            addPersonReq.setGroupIds(Collections.singletonList(1L).toArray(new Long[0]));
//            Integer integer = build.addDeptPerson(addPersonReq);
//            System.out.println(integer);
//        }

//        File file =
//        FileUtil.file("/Users/ryan/Downloads/anson.jpeg");
//        String s = build.uploadAvatar(file);
//        if (StringUtils.isNotBlank(s)) {
//            AddVisitorReq addVisitorReq = new AddVisitorReq();
//            addVisitorReq.setName("anson");
//            addVisitorReq.setMobile("18716451234");
//            addVisitorReq.setDateTimeFrom(DateUtils.format(new Date(), DateUtils.FormatType.COMMON));
//            addVisitorReq.setDateTimeTo(DateUtils.format(DateUtil.offsetDay(new Date(), 1), DateUtils.FormatType.COMMON));
//            addVisitorReq.setGroupIds(Collections.singletonList(3L).toArray(new Long[0]));
//            addVisitorReq.setAvatar(s);
//            Integer integer = build.addVisitor(addVisitorReq);
//            System.out.println(integer);
//        }
    }
}
